{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.4"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3",
   "language": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "source": [
    "# 序列\n",
    "\n",
    "- 序列是 Python 中最基本的数据结构\n",
    "- 数据结构指计算机中数据储存的方式\n",
    "- 序列用于保存一组有序的数据，所有的数据在序列中都有一个唯一的位置（索引），并且序列中的数据会按照添加的顺序来分配索引\n",
    "- 序列的分类：\n",
    "    - 可变序列（序列中的元素可以改变）：\n",
    "        - 列表（list）\n",
    "    - 不可变序列（序列中的元素不可改变）：\n",
    "        - 字符串（str）\n",
    "        - 元组（tuple）\n",
    "    - 刚刚提及的所有操作都是序列的通用操作"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "my_name = 'icekylin'\n",
    "\n",
    "frequency = my_name.count('i') # 2\n",
    "index_of_i = my_name.index('i',1) # 6\n",
    "length = len(my_name) # 8\n",
    "\n",
    "print(f'frequency = {frequency}')\n",
    "print(f'index_of_i = {index_of_i}')\n",
    "print(f'length = {length}')\n",
    "\n",
    "rst_1 = my_name[1:-1:2] # 'ckl'\n",
    "rst_2 = my_name[-2:0:-1] # 'ilykec'\n",
    "\n",
    "print(f'rst_1 = {rst_1}')\n",
    "print(f'rst_2 = {rst_2}')"
   ]
  }
 ]
}